|
|
|
|
|
|
|
Copy another label/text box control set onto the form. Change the label caption property to Counter and the text box DataField property to AutoIncrField. See Figure 2.14 for guidance in positioning and sizing the control. |
|
|
|
|
|
|
|
|
Figure 2.14.
Adding the COUNTER data type to the form. |
|
|
|
|
|
|
|
|
Now save and run the program one more time. Notice that the COUNTER data type already has a value in it, even though you have not entered data into the field. Visual Basic sets the value of COUNTER fields; users do not. Add a new record to the table by pressing the Add button. You see a new value in the COUNTER input control. Visual Basic uses the next available number in sequence. Visual Basic is also able to ensure unique numbers in a multiuser setting. If you have three people running the same program adding records to this table, they will all receive unique values in the Counter text box. |
|
|
|
|
| |
|
|
|
|
You should never attempt to edit the value in the COUNTER text box! If Visual Basic determines that the counter value has been changed, it displays a Visual Basic error message, and you cannot save the record. Even if you reset the value in the COUNTER data field back to its original value, Visual Basic refuses to save the record. |
|
|
|
|
|
|
|
|
|
|
Additional Visual Basic Data Types |
|
|
|
|
|
|
|
|
The rest of the Visual Basic data types (INTEGER, SINGLE, DOUBLE, TEXT, MEMO, BINARY, LONGBINARY, and GUID) are rather unspectacular when placed on a form. The following are some notes on the various Visual Basic data types that you should keep in mind when you are designing your data tables. |
|
|
|
|
|
|
|
|
· Visual Basic returns an error if you enter more than the maximum number of characters into a TEXT data field. |
|
|
|
|
|
|
|
|
· The LONGBINARY data field is used to store graphic image data and allows any alphanumeric data to be entered and saved. The storage of graphic data is covered later in the book (see Day 11, ''Displaying Your Data with Graphs"). |
|
|
|
|
|